
#ifndef CUTOFFOPERATION_H
#define CUTOFFOPERATION_H

#include <BMap>
#include <BHBoxLayout>
#include <BButton>

#include "Operation.h"

class CutoffOperation : public Operation
{
public:
	CutoffOperation();
	~CutoffOperation();

protected:
	void freshPartRects();
	void applyPartDraging(const BPoint& pos);

protected:
	void slotApplyButtonClicked();
	void slotCancelButtonClicked();

private:
	virtual void attached(BWidget* widget);
	virtual void detached(BWidget* widget);

	virtual void paint(BPainter& painter);
	virtual void update(double time);

	virtual void freshEvent(const BEvent& event);
	virtual bool focusEvent(const BEvent& event);
	virtual bool keyDownEvent(const BKeyEvent& keyEvent);
	virtual bool keyUpEvent(const BKeyEvent& keyEvent);

	virtual bool mouseEnterEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseLeaveEvent(const BMouseEvent& mouseEvent);
	virtual bool mousePressEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseReleaseEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseMoveEvent(const BMouseEvent& mouseEvent);

	virtual bool mouseWheelEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseClickEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseDoubleClickEvent(const BMouseEvent& mouseEvent);

private:
	BHBoxLayoutHolder	_layout;
	BButton*			_applyButton;
	BButton*			_cancelButton;

	BPoint				_hoverPoint;
	BPoint				_pressPoint;
	BRect				_selectRect;
	bool				_draging;
	BPoint				_dragPoint;
	Part				_dragPart;
	BMap<PartFlag, BRect>	_dragRectMap;
};

#endif
